<?php

class core
{

    private $clientServer = [];
    private $clientHeader = [];
    private $request;

    public function __construct()
    {
        $this->clientServer = $_SERVER;

        $this->clientHeader = getallheaders();
        $this->run();
    }

    private function run()
    {
        $uri = $this->clientServer['REQUEST_URI'];
        $url = parse_url($uri);
        // var_dump($url);
        $path  = ltrim($url['path'], '/');
        $route = explode('/', $path);
//        var_dump($route);
        $controller       = isset($route[0]) ? $route[0] : 'index';
        $action           = isset($route[1]) ? $route[1] : 'index';
        $controller_class = 'app\\controller\\' . ucfirst($controller) . 'Controller';

        (new $controller_class)->$action();
    }
}
